﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
using System.ComponentModel.DataAnnotations.Schema;
using System.Web.Providers.Entities;
using System.ComponentModel.DataAnnotations;

namespace Leiktuther.Models
{
    public class AppDataContext : DbContext
    {
        public DbSet<Game> Games { get; set; }
        public DbSet<Statistic> Statistics { get; set; }
        public DbSet<GameInstance> GameInstances { get; set; }
        public DbSet<Player> Players { get; set; }
    }
    
    public class Game
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public int maxPlayers { get; set; }
        public string GameRefer { get; set; }
        public string BaseFolder { get; set; }
        public string BaseUrl { get; set; }
    }

    public class GameInstance
    {
        public int ID { get; set; }
        public int CreatorID { get; set; }
        public string Name { get; set; }
        public int GameID { get; set; }
        public bool isActivated { get; set; }
        public bool hasBegun { get; set; }
        public bool finished { get; set; }
        public string GameName { get; set; }
        public int Player1 { get; set; }
        public int Player2 { get; set; }

        [ForeignKey("CreatorID")]
        public virtual Player Player { get; set; }

        [ForeignKey("GameID")]
        public virtual Game Game { get; set; }
    }

    public class Statistic
    {
        public int ID { get; set; }
        public int PlayerID { get; set; }
        public int GameID { get; set; }
        public int TotalGames { get; set; }
        public int Win { get; set; }
        public int Draw { get; set; }
        public int Loss { get; set; }
        

        [ForeignKey("PlayerID")]
        public virtual Player Player { get; set; }

        [ForeignKey("GameID")]
        public virtual Game Game { get; set; }
    }

    public class Player : LogOnModel
    {
        [Key]
        public int ID { get; set; }
        public Guid UserID { get; set; }
       // public string UserName { get; set; }
        public string Email { get; set; }
        public string Category { get; set; }

        [ForeignKey("UserID")]
        public virtual User User { get; set; }
    }
}